selected_indices = set()
for i in range(k):
    idx = diff[i][1]
    total += reward1[idx]
    selected_indices.add(idx)

for i in range(n):
    if i not in selected_indices:
        total += reward2[i]